package com.ruoyi.web.controller.operation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.GwPlatformAccount;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwOperationAccount;
import com.ruoyi.system.service.IGwOperationAccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 运营账号Controller
 * 
 * @author ruoyi
 * @date 2025-05-08
 */
@Api(description = "平台运营管理-用户账号管理")
@RestController
@RequestMapping("/system/operationAccount")
public class GwOperationAccountController extends BaseController
{
    @Autowired
    private IGwOperationAccountService gwOperationAccountService;

    /**
     * 查询运营账号列表
     */
    @ApiOperation("查询运营账号列表-分页")
    @GetMapping("/list")
    public TableDataInfo list(GwOperationAccount gwOperationAccount)
    {
        startPage();
        List<GwOperationAccount> list = gwOperationAccountService.selectGwOperationAccountList(gwOperationAccount);
        return getDataTable(list);
    }

    /**
     * 导出运营账号列表
     */
    @PreAuthorize("@ss.hasPermi('system:operationAccount:export')")
    @Log(title = "运营账号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwOperationAccount gwOperationAccount)
    {
        List<GwOperationAccount> list = gwOperationAccountService.selectGwOperationAccountList(gwOperationAccount);
        ExcelUtil<GwOperationAccount> util = new ExcelUtil<GwOperationAccount>(GwOperationAccount.class);
        util.exportExcel(response, list, "运营账号数据");
    }

    /**
     * 获取运营账号详细信息
     */
    @ApiOperation("查询运营账号详细信息")
    @PreAuthorize("@ss.hasPermi('system:operationAccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwOperationAccountService.selectGwOperationAccountById(id));
    }

    /**
     * 新增运营账号
     */
    @ApiOperation("新增运营账号")
    @PreAuthorize("@ss.hasPermi('system:operationAccount:add')")
    @Log(title = "运营账号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwOperationAccount gwOperationAccount)
    {
        return gwOperationAccountService.insertGwOperationAccount(gwOperationAccount);
    }

    /**
     * 修改运营账号
     */
    @ApiOperation("修改运营账号")
    @PreAuthorize("@ss.hasPermi('system:operationAccount:edit')")
    @Log(title = "运营账号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwOperationAccount gwOperationAccount)
    {
        return toAjax(gwOperationAccountService.updateGwOperationAccount(gwOperationAccount));
    }


    /**
     * 删除运营账号
     */
    @ApiOperation("删除运营账号")
    @PreAuthorize("@ss.hasPermi('system:operationAccount:remove')")
    @Log(title = "运营账号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gwOperationAccountService.deleteGwOperationAccountByIds(ids));
    }

    /**
     * 重置密码
     * @Date 下午 4:09:16 2025/5/29
     * @param gwOperationAccount
     * @return 结果
     **/
    @Log(title = "运营账号重置密码", businessType = BusinessType.INSERT)
    @PostMapping("/resetPassword")
    public AjaxResult resetPassword(@RequestBody GwOperationAccount gwOperationAccount)
    {
        return toAjax(gwOperationAccountService.resetPassword(gwOperationAccount));
    }
}
